﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Taschenrechner.Properties;

namespace Taschenrechner {

    internal enum ArithmeticOperator {
        add,
        sub,
        multi,
        div
    }

    internal static class ValidChar {
        internal static readonly char[] operators = { '+', '-', '*', '/' };
        internal static readonly char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ',' };
        internal static readonly char separator = ',';
        internal static readonly char[] results = { '=' };
    }

    internal class OperatorMapper {
        internal readonly Dictionary<char, ArithmeticOperator> Operation = new Dictionary<char,ArithmeticOperator>();

        internal OperatorMapper() {
            Operation.Add('+', ArithmeticOperator.add);
            Operation.Add('-', ArithmeticOperator.sub);
            Operation.Add('*', ArithmeticOperator.multi);
            Operation.Add('/', ArithmeticOperator.div);
        }
    }

    internal class Number {

        string charString;
        
        internal string CharString {
            get { return charString; }
        }

        double value;
        internal double Value {
            get { return this.value; }
        }

        private Number() { }

        internal Number(string numberString) {
            if (String.IsNullOrEmpty(numberString)) {
                throw new ArgumentException(Resource.NumberArgumentExceptionString, "numberString");
            }
            charString = numberString;
            try {
                value = Convert.ToDouble(numberString);
            }
            catch (OverflowException) {
                throw new OverflowException(Resource.NumberArgumentExeptionOverflow);
            }
            catch (Exception e) {
                throw e;
            }
        }

        internal Number(double numberValue) {
            value = numberValue;
            charString = numberValue.ToString();
        }

    }

    internal class Term {

        private Number number1;
        internal Number Number1 {
            get { return number1; }
        }
        private Number number2;
        internal Number Number2 {
            get { return number2; }
        }
        private ArithmeticOperator arithmeticOperator;
        internal ArithmeticOperator ArithmeticOperator {
            get { return arithmeticOperator; }
        }

        private Term(){}

        internal Term(Number number1, ArithmeticOperator arithemticOperator, Number number2) {
            this.number1 = number1;
            this.number2 = number2;
            this.arithmeticOperator = arithemticOperator;
        }
    }
}
